#include "CSetMaterialTypeCommand.h"
#include "CUserInterface.h"
#include "CLevelEditor.h"
#include "ISceneManager.h"
#include "ISceneNode.h"

extern CGlobals* g;
extern CUserInterface* ui;
extern CLevelEditor* editor;

CSetMaterialTypeCommand::CSetMaterialTypeCommand (int id, E_MATERIAL_TYPE newType)
{
	m_id = id;
	m_oldType = g->sceneManager->getSceneNodeFromId(id)->getMaterial(0).MaterialType;
	m_newType = newType;
	setDescription(L"change material");
}

void CSetMaterialTypeCommand::redo ()
{
	g->sceneManager->getSceneNodeFromId(m_id)->getMaterial(0).MaterialType = m_newType;
}

void CSetMaterialTypeCommand::undo ()
{
	g->sceneManager->getSceneNodeFromId(m_id)->getMaterial(0).MaterialType = m_oldType;
}
